const { Comment } = require("../database/sequlize");

// 获取所有提交记录
exports.getAllCommits = async () => {
  return Comment.findAll();
};

// 获取单个提交记录通过id
exports.getCommitById = async (commitId) => {
  return Comment.findByPk(commitId);
};

// 创建新的提交记录
exports.createCommit = async (commitData) => {
  return Comment.create(commitData);
};

// 删除提交记录
exports.deleteCommit = async (commitId) => {
  const commit = await Comment.findByPk(commitId);
  if (!commit) {
    throw new Error("Comment not found");
  }
  return commit.destroy();
};
